# 加载代码
path = File.dirname(__FILE__).force_encoding('utf-8')
files = [
 
File.join(path, 'chen_RebarTools_DLSTS/diskLockSteelTubularScaffold.rb'),

 #File.join(path, 'chen_RebarTools/cube.html')
]
files.each{|file|
 next unless File.file?(file)
 load file
}

# 新增工具条
menu = UI.menu('Extensions')
toolbar = UI::Toolbar.new "钢之术士——参数盘扣工具条1.0"


cmd = UI::Command.new("createStandard"){

    model = Sketchup.active_model
    prompts = ["立杆模数m"]
  	defaults = ["2.5"]
  	input = UI.inputbox(prompts, defaults, "创建立杆")
    group = model.active_entities.add_group
    #puts File.dirname(__FILE__).force_encoding('utf-8')
    DLSTS.new().createStandard(input[0].to_f,group)
}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/Standard.png"
cmd.tooltip = "创建立杆"
cmd.status_bar_text = "这是创建立杆的按钮"
toolbar.add_item cmd



cmd = UI::Command.new("createLedger"){

    model = Sketchup.active_model
    group = model.active_entities.add_group

    prompts = ["水平模数m"]
  	defaults = ["1.2"]
  	input = UI.inputbox(prompts, defaults, "创建水平杆")
    
    
    DLSTS.new().createLedger(input[0].to_f,group)
}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/Ledger.png"
cmd.tooltip = "创建水平杆"
cmd.status_bar_text = "这是创建水平杆的按钮"
toolbar.add_item cmd



cmd = UI::Command.new("diagonalBrace"){

    model = Sketchup.active_model
    group = model.active_entities.add_group

    prompts = ["水平模数m","立杆模数m"]
  	defaults = ["1.2","2.5"]
  	input = UI.inputbox(prompts, defaults, "创建竖斜杆")
    
    
    DLSTS.new().diagonalBrace(input[0].to_f,input[1].to_f,group)
}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/diagonalBrace.png"
cmd.tooltip = "创建竖斜杆"
cmd.status_bar_text = "这是创建竖斜杆的按钮"
toolbar.add_item cmd



cmd = UI::Command.new("baseJack"){

    model = Sketchup.active_model
    group = model.active_entities.add_group

    prompts = ["螺杆长度mm","伸出长度mm"]
  	defaults = ["450","200"]
  	input = UI.inputbox(prompts, defaults, "创建可调底座")
    
    
    DLSTS.new().baseJack(input[0].to_f.mm,input[1].to_f.mm,group)
}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/baseJack.png"
cmd.tooltip = "创建可调底座"
cmd.status_bar_text = "这是创建可调底座的按钮"
toolbar.add_item cmd



cmd = UI::Command.new("headJack"){

    model = Sketchup.active_model
    group = model.active_entities.add_group

    prompts = ["螺杆长度mm","伸出长度mm"]
  	defaults = ["450","200"]
  	input = UI.inputbox(prompts, defaults, "创建可调顶托")
    
    
    DLSTS.new().headJack(input[0].to_f.mm,input[1].to_f.mm,group)
}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/headJack.png"
cmd.tooltip = "创建可调顶托"
cmd.status_bar_text = "这是创建可调顶托的按钮"
toolbar.add_item cmd



cmd = UI::Command.new("V_cp"){

    model = Sketchup.active_model
    group = model.active_entities.add_group

    prompts = ["可调底座螺杆长度mm","可调底座伸出长度mm","可调顶托伸出长度mm","可调顶托伸出长度mm","立杆模数组1,2,3"]
  	defaults = ["450","200","450","200","1,2,3"]
  	input = UI.inputbox(prompts, defaults, "创建立杆体系")
    
    stdArray = input[4].split(",").map { |item| item.to_f }

    puts stdArray

    DLSTS.new().V_cp(input[0].to_f.mm,input[1].to_f.mm,input[2].to_f.mm,input[3].to_f.mm,stdArray,group)

}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/V_cp.png"
cmd.tooltip = "创建立杆体系"
cmd.status_bar_text = "这是创建立杆体系的按钮"
toolbar.add_item cmd


cmd = UI::Command.new("singleDL"){

    model = Sketchup.active_model
    group = model.active_entities.add_group

    prompts = ["立杆数组","水平杆数组","竖斜杆数组"]
  	defaults = ["0.7,0.2,0.6,0.15,3,2,1","0.9,0,3,6,9,11","0.9,1.5,0,3,6"]
  	input = UI.inputbox(prompts, defaults, "创建单榀体系")

    vcpArray = input[0].split(",").map { |item| item.to_f }
    ldgArray = input[1].split(",").map { |item| item.to_f }
    dgbArray = input[2].split(",").map { |item| item.to_f }
    
    DLSTS.new().singleDL(vcpArray,ldgArray,dgbArray,group)
}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/singleDL.png"
cmd.tooltip = "创建单榀体系"
cmd.status_bar_text = "这是创建单榀体系的按钮"
toolbar.add_item cmd


cmd = UI::Command.new("multiple"){

    model = Sketchup.active_model
    group = model.active_entities.add_group

    prompts = ["vip服务","会员服务"]
  	defaults = ["450","200"]
  	input = UI.inputbox(prompts, defaults, "创建多跨矩形体系")
    
    
    
}
cmd.large_icon = cmd.small_icon = "chen_RebarTools_DLSTS/image/multiple.png"
cmd.tooltip = "创建多跨矩形体系"
cmd.status_bar_text = "这是创建多跨矩形体系的按钮"
toolbar.add_item cmd








toolbar.show
#menu.add_item cmd
